<?php
class ml_biz_feed_albumreply{
    private $_data;
    private $_uid;
    private $_uids = array();
    private $_nicks;
    private $_is_hide = false;
    private $_hide_array = array();
    private $_hide_start = 3;
    private $_hide_end = 10;
    public function __construct(){
        
    }
    
    public function initParam($option){
        $this->_uid = $option['uid'];
        $this->_data = $option['data'];
        $this->_is_hide = $option['is_hide'];
    }
    
    private function _init_intra_param(){
        foreach($this->_data as $vo){
            $this->_uids[] = $vo['uid'];
        }
        if($this->_is_hide){
            $this->_get_hide_key();
        }
        $this->_uids = array_unique($this->_uids);
        return true;
    }
    
    private function _get_hide_key(){
        for($i=$this->_hide_start;$i<$this->_hide_end;$i++){
            $this->_hide_array[] = $i;
        }
        return true;
    }
    
    private function _get_nick(){
        $this->_nicks = ml_tool_nick::uids2nicks($this->_uids);
        return true;
    }
    
    private function _format_user($uid)
    {
        return  array(
                'uid' => $uid,
                'nick' => Tool_string::un_html($this->_nicks[$uid]),
                'homeurl' => ml_tool_urlMaker::person_index($uid),
                'portrait' => ml_tool_picid::uid2portrait($uid,'tny')
        );
    }

    private function _deal_data(){
        foreach ($this->_data as $key=>$vo){
            $this->_data[$key]['user'] = $this->_format_user($vo['uid']);
            $this->_data[$key]['content'] = ml_tool_formatContent::format_content($vo['content']);
            $this->_data[$key]['ctime'] = ml_tool_standardShow::time($vo['ctime']);
            if($this->_is_hide && in_array($key, $this->_hide_array))
                $this->_data[$key]['is_hide'] = true;
            if(!empty($this->_uid) && ($this->_uid == $vo['uid']))
                $this->_data[$key]['is_del'] = true;
            else
                $this->_data[$key]['is_del'] = false;
                
        }
        return true;
    }
    
    public function parse(){
        $this->_init_intra_param();
        $this->_get_nick();
        $this->_deal_data();
    }
    public function create_html($is_all=true){
        $this->parse();
        foreach($this->_data as $vo){
            $html[] = ml_tool_template::parseModTpl($vo, 'pub_feed::albumreply');
        }
        if($is_all)
            return $html;
        else
            return $html[0];
    }
}
?>